package com.myblog.controller;


import com.myblog.common.lang.Result;
import com.myblog.entity.User;
import com.myblog.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mochuy：myblog
 * @since 2021-04-27
 */
@RestController
@RequestMapping("/user")
public class UserController {
  @Autowired
    UserService userService;
  @RequiresAuthentication
  @GetMapping("/index")
    public  Object index(){
    User user = userService.getById(1L);

    return Result.succ(user);
  }

  /**
   * 测试实体
   * @param user
   * @return
   */
  @PostMapping("/save")
  public Object testUset(@Validated @RequestBody User user){
    System.out.println(user.toString());
    return Result.succ(user);
  }
}
